package com.gzxw.mogublog.admin.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gzxw.mogublog.commons.entity.Picture;
import com.gzxw.mogublog.commons.entity.PictureSort;
import com.gzxw.mogublog.utils.R;
import com.gzxw.mogublog.xo.service.PictureService;
import com.gzxw.mogublog.xo.vo.PictureVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/picture")
public class PictureController {

    @Autowired
    private PictureService pictureService;

    @PostMapping("/getList")
    public R getList(@RequestBody PictureVO pictureVO) {

        IPage<Picture> pageList = pictureService.getPageList(pictureVO);
        Map<String, Object> result = new HashMap<>();
        List<Picture> records = pageList.getRecords();
        long total = pageList.getTotal();
        long size = pageList.getSize();
        long current = pageList.getCurrent();
        result.put("records", records);
        result.put("total", total);
        result.put("size", size);
        result.put("current", current);

        return R.success("返回成功",result);
    }


    @PostMapping("/delete")
    public R deleteBatch(@RequestBody PictureVO pictureVO) {

       String message =  pictureService.deleteBatchPicture(pictureVO);

        return R.success("200",message);
    }


}
